<%--
 *  @Author: Kevinfan
 *  Date:    4/11/2011
 *
 *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
  //init param
  Category cat = Category.getInstance("jsp.PharmacyPurchaseTypein");
  String strModuleName = "TDR";
  String privilegeCode = "A0403";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/Security.inc"%>
<%@ include file="/inc/PageDefault.inc"%>
<%@ include file="/inc/LocationDefault.inc"%>
<html>
<head>
<title>PharmacyPurchaseTypein</title>
<PageFlow:CheckPageFlow pageName="p_datatypeinnew" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/cn/main.css"
	type="text/css">
<link rel="stylesheet" href="<%=contextPath%>/css/autocomplete.css"
	type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/keyFunction.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/spellcode/yahoo-dom-event.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/spellcode/animation-min.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/spellcode/autocomplete.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/spellcode/spellCodeAutoComplete.js"></script>
<script type="text/javascript" src="ZopSaleOrderNew.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/artDialog/artDialog.source.js?skin=default"></script>
<script type="text/javascript" src="<%=contextPath%>/js/artDialog/plugins/iframeTools.source.js"></script>
<%@ include file="/inc/NewCalendar.inc"%>
<%@ include file="/inc/SummaryDivision.inc"%>
<script language="JavaScript">
	
<%
	String year = ((Integer)pageContext.getAttribute("year")).toString();
	String month = ((Integer)pageContext.getAttribute("month")).toString();
	String result = (String)pageContext.getAttribute("result");
	Integer count = (Integer)pageContext.getAttribute("count");
	String optionvalue = (String)pageContext.getAttribute("endday1");
	Vector totalsummary = null;
	if(count.intValue() == 0){
		totalsummary = new Vector();
	}else{
		totalsummary = (Vector)pageContext.getAttribute("totalsummary");
	}
	java.util.Calendar cal = java.util.Calendar.getInstance();      
	int day = cal.get(Calendar.DAY_OF_MONTH);
	String periodflag = "false";
	int j = 5;
	if("Y".equals(optionvalue)){
             periodflag = "true";}
	
	if(totalsummary.size()!=0)j=totalsummary.size();
	if(totalsummary.size()==0 && (result.equals("false") || periodflag.equals("false")))j=0;
	if(totalsummary.size()==0 && (month.equals("1") && periodflag.equals("true")))j=5;
%>
var trClone = null;
jQuery(function() {
	trClone = document.getElementById("salesList").children[1].innerHTML;
});
function page_selectbyDate(){
	var year = document.cform.year.value;
	var month = document.cform.month.value;
	self.location="<%=contextPath%>/tdr/datatypein/HospitalSalesTypeinNew.jsp?<%= OvalTools.randomURL() %>&businesstype=150&year="+year+"&month="+month;
}
function isNullOrEmpty(strVal) {
	if (strVal == '' || strVal == null || strVal == undefined) {
	  return true;
	} else {
	  return false;
	}
}
function dealerSelector(id) {
	$('input[name=currentnum]').val(id);
	var url = "./HospitalSelectPopNew.jsp";
	art.dialog.open(url,{
        id: 'hospital',
		title:'医院选择',
		lock:true,
		background: '',
        content: '',
		width:600,
		height:400
    });
}
function productSelector(index) {
	$('input[name=currentnum]').val(index);
	var hospitalid=$('input[name=dealerid'+index+']').val();
	if(isNullOrEmpty(hospitalid)){
		alert("请先选择医院！");
	    return;
	}
	var year = document.cform.year.value;
	var month = document.cform.month.value;
	var url = "./ProdSelectPopNew.jsp?hospitalid="+hospitalid+"&year="+year+"&month="+month+"&maxitem=10";
	art.dialog.open(url,{
        id: 'product',
		title:'产品选择',
		lock:true,
		background: '',
        content: '',
		width:600,
		height:400
    });
}

function page_setHospital(id,name,code,level)
{	
	var index=$('input[name=currentnum]').val();
	if($('input[name=dealerid'+index+']').val() != id){
		$('input[name=productid'+index+']').val();
		$('input[name=productcode'+index+']').val();
		$('input[name=productname'+index+']').val();
	}
	$('input[name=dealerid'+index+']').val(id);
	$('input[name=dealercode'+index+']').val(code);
	$('input[name=dealername'+index+']').val(name);
	$('input[name=attr21'+index+']').val(level);
}
function page_setProduct(id,code,name,price,spec)
{	
	var index=$('input[name=currentnum]').val();
	$('input[name=productid'+index+']').val(id);
	$('input[name=productcode'+index+']').val(code);
	$('input[name=productname'+index+']').val(name);
	$('input[name=specifications'+index+']').val(spec);
	$('input[name=price'+index+']').val(price);
	
	//page_department(index);
	//setTimeout("page_department("+index+");","400");
	setTimeout("page_getInitialqty("+index+");","250");
	
}
function page_getInitialqty(idx){
	var orgid=$('input[name=dealerid'+idx+']').val();
	var productid=$('input[name=productid'+idx+']').val();
	var businessdate =$('input[name=businessdate'+idx+']').val();
	var datahandler = new  DataHandler();
	datahandler.add_params("orgid" , orgid, 'Integer');
	datahandler.add_params("prodid" , productid, 'Integer');
	datahandler.add_params("businessdate" , businessdate, 'Date');
	//datahandler.getResultFromHashMap("onehash","endqty","document.cform.openingnumber"+idx);
	datahandler.getResultFromHashMap("onehash","safeqty","document.cform.pagesafestock");
	datahandler.add_job("j_getendqty");
	
	datahandler.runDataHandler();
	setTimeout("page_setInitialqty("+idx+");","300");
}
 
function page_setInitialqty(idx){
	/*var openingnumber=$('input[name=openingnumber'+idx+']').val();
	if(isNullOrEmpty(openingnumber)){
		$('input[name=openingnumber'+idx+']').val("");
	}else{
		$('input[name=openingnumber'+idx+']').val(openingnumber);
	}*/
	var pagesafestock = $('input[name=pagesafestock]').val();
	if(isNullOrEmpty(pagesafestock) || pagesafestock == "null"){
		$('input[name=safestock'+idx+']').val("0");
	}else{
		$('input[name=safestock'+idx+']').val(pagesafestock);
	}
	//setTimeout("page_department("+idx+");","250");
}
function page_department(idx){
	var orgid =$('input[name=dealerid'+idx+']').val();
	var employeeid = $('input[name=maker'+idx+']').val();
	var productid = $('input[name=productid'+idx+']').val();
	if(orgid == "" || orgid == "null"){
		//document.getElementById("tr"+idx).cells[10].innerHTML = "&nbsp;";
		return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("querytype" , 2, 'Integer');
	datahandler.add_params("orgid" , orgid, 'Integer');
	datahandler.add_params("employeeid" , employeeid, 'Integer');
	datahandler.add_params("productid" , productid, 'Integer');
	datahandler.getResultFromHashMap("onehash","productgroupid","document.cform.productgroupid"+idx);
	datahandler.getResultFromHashMap("onehash","productgroupcode","document.cform.productgroupcode"+idx);
	datahandler.getResultFromHashMap("onehash","productgroupname","document.cform.productgroupname"+idx);
	datahandler.add_job("j_selectgroup");
	datahandler.runDataHandler();
	//setTimeout("page_setGroupValue("+idx+");","250");
	setTimeout("page_getInitialqty("+idx+");","250");
}
function page_delOneDetail(id) {
	document.cform.onedetailid.value = id;
	document.cform.actionname.value = "delsalesdata150";
    document.cform.target = "_self";
    isRunning = true;
	document.cform.submit();
}	
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "HospitalSalesTypeinNew.jsp?<%= OvalTools.randomURL() %>&businesstype=150";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}
function changeSales(i){
	$("#salesTbody tr").eq(i).children().eq(0).children().eq(0).attr("name", 'dealercode' + i + '');
	$("#salesTbody tr").eq(i).children().eq(0).children().eq(1).attr("name", 'dealername' + i + '');
	$("#salesTbody tr").eq(i).children().eq(0).children().eq(2).attr("name", 'dealerid' + i + '');
	$("#salesTbody tr").eq(i).children().eq(0).children().eq(3).attr("onclick","dealerSelector("+i+")"); 
	$("#salesTbody tr").eq(i).children().eq(0).children().eq(3).attr("value",i); 
	$("#salesTbody tr").eq(i).children().eq(0).children().eq(3).click(function () { dealerSelector(this.value)});//重新绑定click事件
	
	
	$("#salesTbody tr").eq(i).children().eq(1).children().eq(0).attr("name", 'productcode' + i + '');
	$("#salesTbody tr").eq(i).children().eq(1).children().eq(1).attr("name", 'productname' + i + '');
	$("#salesTbody tr").eq(i).children().eq(1).children().eq(2).attr("name", 'productid' + i + '');
	$("#salesTbody tr").eq(i).children().eq(1).children().eq(3).attr("onclick", 'productSelector(' + i + ')');
	$("#salesTbody tr").eq(i).children().eq(1).children().eq(3).attr("value",i); 
	$("#salesTbody tr").eq(i).children().eq(1).children().eq(3).click(function () { productSelector(this.value)});//重新绑定click事件
	$("#salesTbody tr").eq(i).children().eq(2).children().eq(0).attr("name", 'stockqty' + i + '');
	$("#salesTbody tr").eq(i).children().eq(3).children().eq(0).attr("name", 'safestock' + i + '');
	//$("#salesTbody tr").eq(i).children().eq(3).children().eq(0).attr("name", 'openingnumber' + i + '');
	$("#salesTbody tr").eq(i).children().eq(4).children().eq(0).attr("name", 'description' + i + '');
	
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(1).attr("name", 'attr21' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(2).attr("name", 'price' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(3).attr("name", 'amount' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(4).attr("name", 'specifications' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(5).attr("name", 'productgroupid' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(6).attr("name", 'productgroupcode' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(7).attr("name", 'productgroupname' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(8).attr("name", 'year' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(9).attr("name", 'month' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(10).attr("name", 'businesstype' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(11).attr("name", 'maker' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(12).attr("name", 'salesmanid' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(13).attr("name", 'salesman' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(14).attr("name", 'salesmanname' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(15).attr("name", 'areacode' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(16).attr("name", 'areaname' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(17).attr("name", 'parentemployeeid' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(18).attr("name", 'parentemployeecode' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(19).attr("name", 'parentemployeename' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(20).attr("name", 'prarentareaname' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(21).attr("name", 'prarentareacode' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(22).attr("name", 'deptid' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(23).attr("name", 'deptname' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(24).attr("name", 'deptcode' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(25).attr("name", 'cityname' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(26).attr("name", 'citycode' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(27).attr("name", 'businessdate' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(28).attr("name", 'status' + i + '');
	$("#salesTbody tr").eq(i).children().eq(5).children().eq(29).attr("name", 'openingnumber' + i + '');
}
function addSales(id) {
	var tabBody = document.getElementById("salesList").children[1];
	$("#salesTbody").append(trClone);
	//console.log("tabBody.children.length"+tabBody.children.length);
	for (i = 0; i <= tabBody.children.length - 1; i++) { // 循环行
		changeSales(i);
	}
	$('input[name=numrows]').val(tabBody.children.length);
}
function delSales(obj) {
	$(obj).parent().parent().remove();
	var tabBody = document.getElementById("salesList").children[1];
	for (i = 0; i <= tabBody.children.length - 1; i++) { // 循环行
		changeSales(i);
	}
	$('input[name=numrows]').val(tabBody.children.length);

}
function page_save(q){
	var reg = /^[1-9]\d*|0$/;
	var tabBody = document.getElementById("salesList").children[1];
	for (i = 0; i <= tabBody.children.length - 1; i++) { // 循环行
		var dealerid=$("#salesTbody tr").eq(i).children().eq(0).children().eq(2);
		var productid=$("#salesTbody tr").eq(i).children().eq(1).children().eq(2);
		var stockqty = $("#salesTbody tr").eq(i).children().eq(2).children().eq(0);
		var safestock = $("#salesTbody tr").eq(i).children().eq(3).children().eq(0);
		
		var price=$("#salesTbody tr").eq(i).children().eq(5).children().eq(3);
		
		var productgroupid = $("#salesTbody tr").eq(i).children().eq(5).children().eq(5);
		var productgroupcode = $("#salesTbody tr").eq(i).children().eq(5).children().eq(6);
		var productgroupname = $("#salesTbody tr").eq(i).children().eq(5).children().eq(7);
		if(isNullOrEmpty(dealerid.val())){
			alert("请先选择医院！");
		    return;
		}
		if(isNullOrEmpty(productid.val())){
			alert("请先选择产品！");
		    return;
		}
		if(isNullOrEmpty(stockqty.val()) || !reg.test(stockqty.val())){
		    alert("填报库存不得小于0");
		    stockqty.val("");
		    stockqty.focus();
		    return;
		}
		if(isNullOrEmpty(safestock.val())){
		    alert("安全库存必填!");
		    safestock.val("");
		    safestock.focus();
		    return;
		}
		if(Number(stockqty.val()) < Number(safestock.val())){
			alert("填报库存不得小于该医院安全库存值:" + safestock.val());
			stockqty.val("");
		    stockqty.focus();
			return;
		  }
		if(productgroupid.val()== "null"){
			productgroupid.val("");
		}
		if(productgroupcode.val()== "null"){
			productgroupcode.val("");
		}
		if(productgroupname.val()== "null"){
			productgroupname.val("");
		}
		$("#salesTbody tr").eq(i).children().eq(5).children().eq(3).val(Number(Number(price.val())*Number(stockqty.val())));
	}
	
	$('input[name=numrows]').val(tabBody.children.length);
	if(q==1)
		document.cform.strstatus.value = "10";
	else
		document.cform.strstatus.value = "40";
	document.cform.actionname.value = "saves";
    document.cform.target = "_self";
    isRunning = true;
	document.cform.submit();
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
	scroll="no" class="yui-skin-sam">
	<iframe id="reloadHandler" name="reloadHandler" style="display: none"></iframe>
	<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
		<input type="hidden" name="pagename" value="p_datatypeinnew"> 
		<input type="hidden" name="actionname"> 
		<input type="hidden" name="strstatus"> 
		<input type="hidden" name="safestock">
		<input type="hidden" name="pagesafestock">
		<input type="hidden" name="onedetailid">
		<custom:hidden property="businesstype" />
		<custom:hidden property="currentnum"/>
		<%
		HashMap employeeinfo = (HashMap)pageContext.getAttribute("employeeinfo");
			String salesmanid = "";
			String salesman = "";                
			String salesmanname = "";            
			String areacode = "";                 
			String areaname = "";               
			String parentemployeeid = "";         
			String parentemployeecode =  "";      
			String parentemployeename = "";         
			String cityname =  "";                
			String citycode = "";
			String parentareacode = "";
			String parentareaname = "";
			String deptid = "";
			String deptcode = "";
			String deptname = "";
		if(employeeinfo.size() !=0){
			salesmanid = ((Integer)employeeinfo.get("userid")).toString();
			salesman = (String)employeeinfo.get("employeecode");                
			salesmanname = (String)employeeinfo.get("employeename");            
			areacode =  "";                
			areaname =  "";              
			parentemployeeid = ((Integer)employeeinfo.get("parentemployeeid")).toString();         
			parentemployeecode =  (String)employeeinfo.get("parentemployeecode");      
			parentemployeename = (String)employeeinfo.get("parentemployeename");         
			cityname =   "";                
			citycode =  "";   
			parentareacode =  ""; 
			parentareaname = ""; 
			deptid =  ""; 
			deptcode =  ""; 
			deptname =  ""; 
		}
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
	style="overflow:scroll">
	<tr>
		<td>
		<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="title-big-b-center">
				<table width="100%" cellspacing="0">
					<tr>
						<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Year1") +  label.getLabelName("L_Colon") %></td>
						<td style="width:50px;" class="td_left"><custom:selectdic	property="year" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1" /></td>
						<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Month") +  label.getLabelName("L_Colon") %></td>
						<td style="width:50px;" class="td_left"><custom:selectdic	property="month" dictType="Months" command="notnull"	value="<%=month %>" label="L_Month" /></td>
						<td style="width:50px;"><a onclick="page_selectbyDate()"><img
							src="<%=contextPath%>/images/cn/ss.png" border="0"></a></td>
						<td>
					</tr>
					<tr>
						<td class="title-big-b-center" colspan="6">医院库存录入</td>
					</tr>

				</table>
				</td>
			</tr>
			<tr>
				<td class="title-big-b-center">
				<table width="100%" cellspacing="0" border="1"
					bordercolorlight="#999999" bordercolordark="#FFFFFF" align="left"
					style="margin-left:-3;">
					<tr>
						<td class="td-text" width="20%"><%= label.getLabelName("L_YearN") + label.getLabelName("L_Colon")%></td>
						<td width="30%">&nbsp;<%=year%></td>
						<td class="td-text" width="20%"><%= label.getLabelName("L_MonthN") + label.getLabelName("L_Colon")%></td>
						<td width="30%">&nbsp;<%=month%></td>
					</tr>
					<tr>
						<td class="td-text"><%= label.getLabelName("L_RegionManager") + label.getLabelName("L_Colon")%></td>
						<td>&nbsp;<%=parentemployeename%></td>
						<td class="td-text"><%= label.getLabelName("L_SalesRep") + label.getLabelName("L_Colon")%></td>
						<td>&nbsp;<%=salesmanname%></td>
					</tr>
				</table>
				</td>
	  </tr>
</table>
<br>
<div id = "mydiv" style="width:100%;height=250;overflow=auto; margin:0 auto;">
	<table width="100%" border="1" cellpadding="0"	bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
		<tr class="deepblue-left">
		    <td width="2%">&nbsp;</td>
		    <td class="title_center" width="16%"><%= label.getLabelName("L_Hospital") %></td>
			<td class="title_center" width="16%"><%= label.getLabelName("L_Products") %></td>
			<td class="title_center" width="8%"><%= label.getLabelName("L_Inventory") %></td>
			<td class="title_center" width="6%"><%= label.getLabelName("L_SafetyStock") %></td>
			<td class="title_center" width="8%"><%= label.getLabelName("L_HospitalGrade") %></td>
			<td class="title_center" width="8%"><%= label.getLabelName("L_Spec") %></td>
			<td class="title_center" width="8%"><%= label.getLabelName("L_InitialQty") %></td>
			<td class="title_center" width="8%"><%= label.getLabelName("L_ProductBusiness") %></td>
			<td class="title_center" width="9%"><%= label.getLabelName("L_Comments") %></td>
			<td class="title_center" width="8%"><%= label.getLabelName("L_CreateDate") %></td>
		    <td width="4%"><%="操作" %>&nbsp;</td>
		</tr>
		<TBODY ID="oTBody">
		   <%
			int i=0;
			String strClassType="";
			String strIsChecked = "Checked";
            Integer nDefaultSalesdataid = new Integer(-1);
            %>
		   <logic:iterate id="onedetail" collection="<%= totalsummary %>" indexId="idx" scope="page">
		    <%
		   		HashMap map = (HashMap)pageContext.getAttribute("onedetail"); 	
		   		if(i%2 == 1)
				{
				    strClassType = "td-listrom";
				}else{                    
				    strClassType = "none";
				}
				if(i != 0)
	            {          
	              strIsChecked = "";
	            }  
	            else
	            {
	              strIsChecked = "Checked";
	            } 
				i++;
		    %>
			<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'" onClick="javascript:radiotrue('tdr_formal_salesdataid<%=JspHelper.filterNull( i )%>');clickSalesdataList('<%=JspHelper.filterNull( map.get("tdr_formal_salesdataid") )%>');" class="<%=JspHelper.filterNull( strClassType )%>">
			   
			    <td><%=i %></td>
			    <td><custom:write name="onedetail" property="dealercode" nbsp="true"/>&nbsp;<custom:write name="onedetail" property="dealername" nbsp="true"/></td>
				<td><custom:write name="onedetail" property="productcode" nbsp="true"/>&nbsp;<custom:write name="onedetail" property="productname" nbsp="true"/></td>
				<td><custom:write name="onedetail" property="stockqty" nbsp="true"/></td>
				<td><custom:write name="onedetail" property="safestock" nbsp="true"/></td>
				<td><custom:write name="onedetail" property="attr21" nbsp="true"/></td>
				<td><custom:write name="onedetail" property="specifications" nbsp="true"/></td>
			    <td><custom:write name="onedetail" property="openingnumber" nbsp="true"/></td>
			    <td><custom:write name="onedetail" property="productgroupname" nbsp="true"/></td>
			    <td><custom:write name="onedetail" property="description" nbsp="true"/></td>
			    <td><custom:write name="onedetail" property="createdate" nbsp="true"/></td>
			    <%if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){%>
			    <td>&nbsp;<a onclick="page_delOneDetail('<custom:write name="onedetail" property="tdr_formal_salesdataid" nbsp="true"/>')"><img src="<%=contextPath%>/images/cn/del1.gif" style="border:none"></a></td>
			    <%}else{ %>
			      <td>&nbsp;</td>
			    <%} %>
			 </tr>
			 </logic:iterate>
			 <input type="hidden" name="tdr_formal_salesdataid" value="<%=JspHelper.filterNull( nDefaultSalesdataid )%>">
		</TBODY>
		<%@ include file="/inc/SummaryActionUP_DH.inc" %>
	</table>
    </div>
 <%if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){%>
    <div style="height=150;overflow=auto;margin:0 auto;overflow-y:scroll;">
      <fieldset>
       <table width="100%" cellspacing="0">
			<tr>
				<td class="td_right">
					<custom:button type="1" label="L_Save" imgsrc="Modify.gif" border="0" onclick="page_save(1);" style="width:55"/>
				</td>
			</tr>
		</table>
       <input type="hidden" name="numrows" >
       <table width="100%" border="1" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" cellspacing="0" class="form-list" id="salesList">
              <tr class="deepblue-left">
                  <th class="title_center" width="25%"><%= label.getLabelName("L_Hospital") %></th>
                  <th class="title_center" width="25%"><%= label.getLabelName("L_ProdName") %></th>
                  <th class="title_center" width="10%"><%= label.getLabelName("L_Inventory") %></th>
                  <th class="title_center" width="10%"><%= label.getLabelName("L_SafetyStock") %></th>
                  <!-- <th class="title_center" width="10%"><%= label.getLabelName("L_InitialQty") %></th> -->
                  <th class="title_center" width="10%"><%= label.getLabelName("L_Comments") %></th>
			      <th class="title_center" width="5%">操作</th>
              </tr>
              <tbody id="salesTbody">
                  <tr>
                   <td class="title_center">
                       <input name="dealercode0" type="text"  />
	                   <input name="dealername0" type="text" />
	                   <input name="dealerid0" type="hidden" />
	                   <a onclick="dealerSelector(0)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                   </td>
                   <td class="title_center">
	                   <input name="productcode0" type="text"  />
	                   <input name="productname0" type="text"  />
	                   <input name="productid0" type="hidden" />
	                   <a onclick="productSelector(0)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                   </td>
                   <td class="title_center"><input type="text" name="stockqty0" size='10' /></td>
                   <td class="title_center"><input type="text" name="safestock0" size='10' readonly="readonly"/></td>
                   <!-- <td class="title_center"><input type="text" name="openingnumber0" size='10' /></td> -->
                   <td class="title_center"><input type="text" name="description0" size='15' /></td>
                   <td class="title_center">
                     <a onclick="delSales(this);"><img src="<%=contextPath%>/images/cn/del1.gif" style="border:none"></a>
                      <input name="attr210" type="hidden"  />
                      <input name="price0" type="hidden" />
                      <input name="amount0" type="hidden" />
                      <input name="specifications0" type="hidden" />
                      <input name="productgroupid0" type="hidden"  />
                      <input name="productgroupcode0" type="hidden"  />
                      <input name="productgroupname0" type="hidden"  />
                      <input name="year0" type="hidden"  value="<%=year%>" />
                      <input name="month0" type="hidden"  value="<%=month%>"/>
                      <input name="businesstype0" type="hidden"  value="150"/>
                      <input name="maker0" type="hidden"  value="<%=salesmanid%>"/>
                      <input name="salesmanid0" type="hidden"  value="<%=salesmanid%>"/>
                      <input name="salesman0" type="hidden"  value="<%=salesman%>"/>
                      <input name="salesmanname0" type="hidden"  value="<%=salesmanname%>"/>
                      <input name="areacode0" type="hidden"  value="<%=areacode%>"/>
                      <input name="areaname0" type="hidden"  value="<%=areaname%>"/>
                      <input name="parentemployeeid0" type="hidden"  value="<%=parentemployeeid%>"/>
                      <input name="parentemployeecode0" type="hidden"  value="<%=parentemployeecode%>"/>
                      <input name="parentemployeename0" type="hidden"  value="<%=parentemployeename%>"/>
                      <input name="prarentareaname0" type="hidden"  value="<%=parentareaname%>"/>
                      <input name="prarentareacode0" type="hidden"  value="<%=parentareacode%>"/>
                      <input name="deptid0" type="hidden"  value="<%=deptid%>"/>
                      <input name="deptname0" type="hidden"  value="<%=deptname%>"/>
                      <input name="deptcode0" type="hidden"  value="<%=deptcode%>"/>
                      <input name="cityname0" type="hidden"  value="<%=cityname%>"/>
                      <input name="citycode0" type="hidden"  value="<%=citycode%>"/>
                      <input name="businessdate0" type="hidden"  value="<%=year+"-"+month+"-1"%>"/>
                      <input name="status0" type="hidden"  value="10"/>
                      <input name="openingnumber0" type="hidden" />
                   </td>
                  </tr>
              </tbody>
              <tr>
    			<td colspan="7" class="td_left">
   				 <%
					if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){
					%>
     			   <a onclick="addSales(5);">
           				 <img src="<%=contextPath%>/images/cn/AddRow.gif" border="0">
       				 </a>
   				 <%}else{%>
    			&nbsp;
   				 <%}%>
    			</td>
			  </tr>
			  <!-- 
              <table width="100%" cellspacing="0">
                <tr> 
                  <td>&nbsp;</td>
                </tr>
				<tr>
					<td class="td_center">
						<custom:button type="1" label="L_Save" imgsrc="Modify.gif" border="0" onclick="page_save(1);" style="width:55"/>
					</td>
				</tr>
			  </table>
			 -->
       </table>
      </fieldset>
  </div>
<%} %>
</form>
<iframe id="dataLoaderIframe" style="display: none; z-index: 5000"></iframe>
</body>
</html>
